package com.xbenben.project.utils.redis;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;

/**
 * @author yu.zhijia
 * Date:2023/6/19 13:57
 **/


// @Configuration
@Slf4j
public class RedisConfig {

    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.port}")
    private int redisPort;

    @Value("${spring.redis.password}")
    private String redisPassword;

    @Bean
    public Jedis jedis() {
        log.info(redisHost + ":" + redisPort);
        Jedis jedis = new Jedis(redisHost, redisPort);
        jedis.auth(redisPassword);
        jedis.select(0);
        return jedis;
    }
}
